
#ifndef __XB_DEV_I2C_H__
#define __XB_DEV_I2C_H__

/* ------------------------------------------------------------------------- */

#define I2C_MCU_ADDR		0x0010
#define I2C_HDTV_ADDR		0x0045
#define I2C_TSNS_ADDR		0x004c
#define I2C_EEPROM_ADDR		0x0054

enum {
	I2C_DEV_MCU,
	I2C_DEV_HDTV,
	I2C_DEV_TSNS,
	I2C_DEV_EEPROM,
	I2C_DEV_NUM,
};

/* ------------------------------------------------------------------------- */

typedef struct {
#ifndef NDEBUG
	char name[10];
#endif
	size_t (fastcall * read)(uint8 cmd, void *data, size_t size);
	size_t (fastcall * write)(uint8 cmd, const void *data, size_t size);
} i2c_dev_t;

/* ------------------------------------------------------------------------- */

capi void fastcall i2c_init(void);

capi i2c_dev_t *get_mcu_device(void);
capi i2c_dev_t *get_hdtv_device(void);

capi void fastcall i2c_device_read(uint16 addr, uint8 cmd, void *buf, size_t size);
capi void fastcall i2c_device_write(uint16 addr, uint8 cmd, const void *buf, size_t size);

/* ------------------------------------------------------------------------- */

#endif
